package com.bls.cate.ui.activity.login;


import android.content.Context;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

import com.blankj.utilcode.util.LogUtils;
import com.bls.cate.R;
import com.bls.cate.mvp.MVPBaseActivity;
import com.bls.cate.mvp.RequestResultState;
import com.lzy.okgo.model.Response;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class LoginActivity extends MVPBaseActivity<LoginContract.View, LoginPresenter> implements LoginContract.View {

    @BindView(R.id.et_username)
    EditText etUsername;
    @BindView(R.id.et_password)
    EditText etPassword;
    @BindView(R.id.btn_login)
    TextView btnLogin;


    @Override
    protected int initLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initFvb() {
        ButterKnife.bind(this);
    }


    @OnClick(R.id.btn_login)
    public void onBtnLoginClicked() {
        mPresenter.onLogin(etUsername, etPassword);
    }

    @Override
    public void onViewLogin(String username, String pwd) {
        mPresenter.requestGetNetData(1, "http://172.18.0.69:8080/Cate/Article/AllOpenArticle", null);
    }

    @Override
    public void onRequestNetResult(int requestId, RequestResultState requestNetState, String responseBody, Response response) {
        super.onRequestNetResult(requestId, requestNetState, responseBody, response);
        LogUtils.i(responseBody);
    }
}
